﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Demos.util;
using mendian;
using Luna小店.DTO;
using Luna小店.service;
using System.IO;
using System.Collections.Specialized;
using Luna小店.UC.面料库存.库存记录.service;
using Luna小店.UC.面料库存.入库.service;

namespace Luna小店.UC.面料库存
{
    public partial class Frm面料预览 : DevExpress.XtraEditors.XtraForm
    {
        private DTO面料库存 DTO面料库存;
        public Frm面料预览(DTO面料库存 DTO面料库存)
        {
            InitializeComponent();
            this.DTO面料库存 = DTO面料库存;
            show详情(this.DTO面料库存);
            //调webservice通过面料id获取出入库记录
            this.gridControl记录.DataSource = 面料记录Service.get单个面料库存记录(this.DTO面料库存.id);
        }
        public void show详情(DTO面料库存 DTO面料库存)
        {
            this.simpleButton确认修改.Enabled = false;
            this.textEdit描述名称.ReadOnly = true;
            this.textEdit供货商.ReadOnly = true;
            this.textEdit成分.ReadOnly = true;
            this.textEdit纱织密度.ReadOnly = true;
            this.textEdit克重.ReadOnly = true;
            this.textEdit幅宽.ReadOnly = true;
            this.textEdit厚度.ReadOnly = true;
            this.textEdit弹力.ReadOnly = true;
            this.textEdit面料特性注意.ReadOnly = true;
            this.textEdit用途.ReadOnly = true;
            this.textEdit延续性.ReadOnly = true;
            this.textEdit验料结果.ReadOnly = true;
            this.textEdit颜色.ReadOnly = true;
            this.textEdit季节.ReadOnly = true;
            this.textEdit风格.ReadOnly = true;
            this.textEdit整理方式.ReadOnly = true;

            this.textEditID.Text = DTO面料库存.id;
            this.textEdit面料号.Text = DTO面料库存.materialNo;
            this.textEdit描述名称.Text = DTO面料库存.meterialDesc;
            this.textEdit供货商.Text = DTO面料库存.vendorName;
            this.textEdit成分.Text = DTO面料库存.composition;
            this.textEdit纱织密度.Text = DTO面料库存.density;
            this.textEdit克重.Text = DTO面料库存.weight;
            this.textEdit幅宽.Text = DTO面料库存.width;
            this.textEdit厚度.Text = DTO面料库存.thick;
            this.textEdit弹力.Text = DTO面料库存.elastic;
            this.textEdit面料特性注意.Text = DTO面料库存.feature;
            this.textEdit用途.Text = DTO面料库存.uasge;
            this.textEdit延续性.Text = DTO面料库存.continuity;
            this.textEdit验料结果.Text = DTO面料库存.inspectionResults;
            this.textEdit颜色.Text = DTO面料库存.color;
            this.textEdit季节.Text = DTO面料库存.season;
            this.textEdit风格.Text = DTO面料库存.style;
            this.textEdit整理方式.Text = DTO面料库存.arrangementMethod;
            this.textEdit库存数量.Text = DTO面料库存.fabricQuanlity.ToString();
            this.textEdit库存成本.Text = DTO面料库存.unitPrice.ToString();
            this.pictureBox面料图片.LoadAsync(URL.图片url + URL.面料图片路径 + RestCall.httpGetMethod(URL.接口url + "/image/getImagePath?materialCode=" + DTO面料库存.materialNo));
        }



        private void pictureBox面料图片_DoubleClick(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "gif,jpg,png|*.gif;*.jpg;*.png;*.jpeg";
            ofd.Title = "请选择图片文件";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                String str = FileService.UploadRequest(URL.接口url + "/image/uploadImage?materialCode=" + DTO面料库存.materialNo, ofd.FileName, Path.GetFileName(ofd.FileName),"file");
                this.pictureBox面料图片.LoadAsync(URL.图片url + URL.面料图片路径 + RestCall.httpGetMethod(URL.接口url + "/image/getImagePath?materialCode=" + DTO面料库存.materialNo));
            }
        }

        private void simpleButton确认修改_Click(object sender, EventArgs e)
        {
            this.DTO面料库存.meterialDesc = this.textEdit描述名称.Text;
            this.DTO面料库存.vendorName = this.textEdit供货商.Text;
            this.DTO面料库存.composition = this.textEdit成分.Text;
            this.DTO面料库存.density = this.textEdit纱织密度.Text;
            this.DTO面料库存.weight = this.textEdit克重.Text;
            this.DTO面料库存.width = this.textEdit幅宽.Text;
            this.DTO面料库存.thick = this.textEdit厚度.Text;
            this.DTO面料库存.elastic = this.textEdit弹力.Text;
            this.DTO面料库存.feature = this.textEdit面料特性注意.Text;
            this.DTO面料库存.uasge = this.textEdit用途.Text;
            this.DTO面料库存.continuity = this.textEdit延续性.Text;
            this.DTO面料库存.inspectionResults = this.textEdit验料结果.Text;
            this.DTO面料库存.color = this.textEdit颜色.Text;
            this.DTO面料库存.season = this.textEdit季节.Text;
            this.DTO面料库存.style = this.textEdit风格.Text;
            this.DTO面料库存.arrangementMethod = this.textEdit整理方式.Text;
            //webservice传值
            面料记录Service.post更新面料详情(this.DTO面料库存);
            MessageBox.Show("更新成功");
            show详情(this.DTO面料库存);
        }

        private void simpleButton可修改_Click(object sender, EventArgs e)
        {
            this.textEdit描述名称.ReadOnly = false;
            this.textEdit供货商.ReadOnly = false;
            this.textEdit成分.ReadOnly = false;
            this.textEdit纱织密度.ReadOnly = false;
            this.textEdit克重.ReadOnly = false;
            this.textEdit幅宽.ReadOnly = false;
            this.textEdit厚度.ReadOnly = false;
            this.textEdit弹力.ReadOnly = false;
            this.textEdit面料特性注意.ReadOnly = false;
            this.textEdit用途.ReadOnly = false;
            this.textEdit延续性.ReadOnly = false;
            this.textEdit验料结果.ReadOnly = false;
            this.textEdit颜色.ReadOnly = false;
            this.textEdit季节.ReadOnly = false;
            this.textEdit风格.ReadOnly = false;
            this.textEdit整理方式.ReadOnly = false;
            this.simpleButton确认修改.Enabled = true;
        }
    }

    
}